/*
 * File:   PathValidatorTest.cpp
 * Author: Guilherme Monteiro
 *
 */

#include "PathValidatorTest.h"

CPPUNIT_TEST_SUITE_REGISTRATION(PathValidatorTest);

PathValidatorTest::PathValidatorTest() {
}

PathValidatorTest::~PathValidatorTest() {
}

void PathValidatorTest::setUp() {
    pathValidator = new PathValidator();
}

void PathValidatorTest::tearDown() {
}

void PathValidatorTest::testValidateDotDot() {
    string path1 = "";
    string path2 = "..";
    string path3 = ".";
    string path4 = "aaaaaa..aaaaa";
    
    bool result1 = pathValidator->validateDotDot(path1);
    bool result2 = pathValidator->validateDotDot(path2);
    bool result3 = pathValidator->validateDotDot(path3);
    bool result4 = pathValidator->validateDotDot(path4);
    
    if ((result1 || result2 || result3) && !result4) {
        CPPUNIT_ASSERT(false);
    }
}

void PathValidatorTest::testValidatePathToPages() {
    string path1 = "/books/caracterizacao/alta_resolucao/image278.png";    
    bool result1 = pathValidator->validatePathToPages(pathValidator->HIGH_PAGE, path1);
    
    string path2 = "/books/caracterizacao/baixa_resolucao/image278.png";
    bool result2 = pathValidator->validatePathToPages(pathValidator->LOW_PAGE, path2);
    
    if (!result1 || !result2) {
        CPPUNIT_ASSERT(false);
    }
}

void PathValidatorTest::testValidatePathToTables() {
    string path1 = "/books/caracterizacao/metadados/tabelasAlta/image278.png";    
    bool result1 = pathValidator->validatePathToTables(pathValidator->HIGH_TABLE, path1);
    
    string path2 = "/books/caracterizacao/metadados/tabelasBaixa/image278.png";
    bool result2 = pathValidator->validatePathToTables(pathValidator->LOW_TABLE, path2);
    
    if (!result1 || !result2) {
        CPPUNIT_ASSERT(false);
    }
}

